function ccR_DeathKnight_2()
	if ccrPlayerLevel() == 90 then
		if OffhandHasWeapon() == nil then
			DeathKnight_Frost_2H_90()
		else
			DeathKnight_Frost_DW_90()
		end;
	end
end

function DeathKnight_Frost_2H_90()
	--[[
		Patch: 5.3 2H
		Source: Noxxic (http://www.noxxic.com/wow/pve/death-knight/frost/dps-rotation-and-cooldowns)
		Talents: 
					[56] Plague Leech
					[57] Anti-Magic Zone
					[58] Death's Advance
					[60] Death Pact
					[75] Runic Empowerment
					[90] Gorefiend's Grasp
		Priority:
			- Single Target -
			1. Frost Fever Blood Plague Maintain at all times.
			2. Soul Reaper on target below 35% Health.
			3. Howling Blast with Rime(Freezing Fog) or to refresh Frost Fever
			4. Obliterate with Killing Machine.
			5. Frost Strike with 0 Frost Runes or to dump RP.
			6. Obliterate with 2 Blood, Frost, or Unholy Runes.
			- AoE -
			1. Howling Blast
			2. Death and Decay

	]]--
	if ccrValidTarget() then
		-- Single target rotation
		local vTargetCount = ccrTargetCount(10)
		if (ccRS.Auto_AoE and (vTargetCount >= 1 and vTargetCount <= 3))
		or (ccrTargetIsBoss() and ccRS.Auto_AoE_Ignore_On_Boss)
		or (not ccRS.Auto_AoE and not ccRS.Manual_AoE)	
		then
			-- 1. Apply Diseases
			if SpellCanAttack("Outbreak")
			and (
				(not ccrTargetHasDebuff("Frost Fever") or not ccrTargetHasDebuff("Blood Plague"))
			or
				(ccrTargetHasDebuffRemaining("Frost Fever", 3) or ccrTargetHasDebuffRemaining("Blood Plague", 3))
				)
			then
				ccrCastAttack("Outbreak")
				return
			else
				-- Frost Fever [Howling Blast]
				if not ccrTargetHasDebuff("Frost Fever")
				and SpellCanAttack("Howling Blast")
				then
					ccrCastAttack("Howling Blast")
					return
				else
					-- Blood Plague [Plague Strike]
					if not ccrTargetHasDebuff("Blood Plague")
					and SpellCanAttack("Plague Strike")
					then
						ccrCastAttack("Plague Strike")
						return
					end
				end
			end;
			-- Diseases are on the target
			if ccrTargetHasDebuff("Frost Fever") and ccrTargetHasDebuff("Blood Plague") then
				-- 2. Soul Reaper on target below 35% Health.
				if ccrTargetHealth() <= 35
				and SpellCanAttack("Soul Reaper")
				then
					ccrCastAttack("Soul Reaper")
					return
				else
					-- 3. Howling Blast with Rime(Freezing Fog) or to refresh Frost Fever
					if ccrPlayerRunicPower() <= 85
					and (ccrPlayerHasBuff("Freezing Fog") or ccrPlayerHasBuffRemaining("Frost Fever", 4))
					and SpellCanAttack("Howling Blast")
					then
						ccrCastAttack("Howling Blast")
						return
					else
						-- 4 Obliterate with Killing Machine.
						if ccrPlayerHasBuff("Killing Machine")
						and SpellCanAttack("Obliterate")
						then
							ccrCastAttack("Obliterate")
							return
						else
							-- 5. Frost Strike with 0 Frost Runes or to dump RP.
							local vRuneA_Start, vRuneA_Duration, vRuneA_RuneReady = GetRuneCooldown(5)
							local vRuneB_Start, vRuneB_Duration, vRuneB_RuneReady = GetRuneCooldown(6)
							if SpellCanAttack("Frost Strike")
							and (not vRuneA_RuneReady and not vRuneB_RuneReady)
							then
								ccrCastAttack("Frost Strike")
								return
							else
								-- 6. Obliterate with 2 Blood, Frost, or Unholy Runes.				
								local vRuneA_Start, vRuneA_Duration, vRuneA_RuneReady = GetRuneCooldown(1)
								local vRuneB_Start, vRuneB_Duration, vRuneB_RuneReady = GetRuneCooldown(2)
								local vRuneC_Start, vRuneC_Duration, vRuneC_RuneReady = GetRuneCooldown(3)
								local vRuneD_Start, vRuneD_Duration, vRuneD_RuneReady = GetRuneCooldown(4)
								local vRuneE_Start, vRuneE_Duration, vRuneE_RuneReady = GetRuneCooldown(5)
								local vRuneF_Start, vRuneF_Duration, vRuneF_RuneReady = GetRuneCooldown(6)
								local vRuneReadyCount = 0
								if vRuneA_RuneReady then vRuneReadyCount = vRuneReadyCount + 1 end
								if vRuneB_RuneReady then vRuneReadyCount = vRuneReadyCount + 1 end
								if vRuneC_RuneReady then vRuneReadyCount = vRuneReadyCount + 1 end
								if vRuneD_RuneReady then vRuneReadyCount = vRuneReadyCount + 1 end
								if vRuneE_RuneReady then vRuneReadyCount = vRuneReadyCount + 1 end
								if vRuneF_RuneReady then vRuneReadyCount = vRuneReadyCount + 1 end

								--if (vRuneA_RuneReady and vRuneB_RuneReady)
								--or (vRuneC_RuneReady and vRuneD_RuneReady)
								--or (vRuneE_RuneReady and vRuneF_RuneReady)
								if vRuneReadyCount >= 2
								and SpellCanAttack("Obliterate")
								then
									ccrCastAttack("Obliterate")
									return
								else
									if SpellCanAttack("Frost Strike") then ccrCastAttack("Frost Strike") end
								end
							end						
						end
					end
				end
			end
		end
		-- AoE Rotation
		if (ccRS.Auto_AoE and vTargetCount >= 4)
		or (not ccRS.Auto_AoE and ccRS.Manual_AoE)
		then
			-- Ensure we dont cap runic power
			if SpellCanAttack("Frost Strike")
			and (ccrPlayerRunicPower() >= 85 or ccrPlayerHasBuff("Killing Machine"))
			then
				ccrCastAttack("Frost Strike")
				return
			else			
				-- Death and Decay
				local vRuneA_Start, vRuneA_Duration, vRuneA_RuneReady = GetRuneCooldown(5)
				local vRuneB_Start, vRuneB_Duration, vRuneB_RuneReady = GetRuneCooldown(6)
	
				if SpellIsReady("Death and Decay") 
				and not vRuneA_RuneReady
				and not vRuneB_RuneReady
				then
					ccrCast("Death and Decay")
					if SpellIsTargeting() == 1 then CastAtLocation(Target:GetLocation()) end;			
				else
					-- Howling Blast
					if SpellCanAttack("Howling Blast") then ccrCastAttack("Howling Blast") end;
					-- Ensure Blood Plague is applied for Rolling Blood
					if PlayerHasTalent("Roiling Blood")
					and not ccrTargetHasDebuff("Blood Plague")
					and (SpellCanAttack("Outbreak") or SpellCanAttack("Plague Strike"))
					then
						if SpellCanAttack("Outbreak") then ccrCastAttack("Outbreak") end;
						if SpellCanAttack("Plague Strike") then ccrCastAttack("Plague Strike") end;
					end					
				end				
			end
		end
	end
end

function DeathKnight_Frost_DW_90()
	--[[
		Patch: 5.4.7 DW
		Source: Noxxic (http://www.noxxic.com/wow/pve/death-knight/frost/dps-rotation-and-cooldowns)
	]]--	
	-- Functions.lua
	ccR_DeathKnight_DeathStrike()
	ccR_DeathKnight_PillarOfFrost()
	ccR_DeathKnight_RaiseDead()
	ccR_DeathKnight_PillarOfFrost()
	-- Talents.lua
	ccR_DeathKnight_RoilingBlood()
	ccR_DeathKnight_PlagueLeech()
	ccR_DeathKnight_UnholyBlight()
	ccR_DeathKnight_LichborneHealing()
	ccR_DeathKnight_AntiMagicZone()
	ccR_DeathKnight_Deaths_Advance()
	ccR_DeathKnight_Asphyxiate()
	ccR_DeathKnight_Death_Pact()
	ccR_DeathKnight_DeathSiphon()
	ccR_DeathKnight_Conversion()
	ccR_DeathKnight_BloodTap()
	ccR_DeathKnight_GorefiendsGrasp()
	ccR_DeathKnight_RemorselessWinter()
	-- Abilities.lua
	ccR_DeathKnight_MindFreeze()
	ccR_DeathKnight_Strangulate()
	ccR_DeathKnight_ChainsOfIce()
	ccR_DeathKnight_Dark_Simulacrum()

	-- Single target rotation
	local vTargetCount = ccrTargetCount(10)
	if (ccRS.Auto_AoE and (vTargetCount >= 1 and vTargetCount <= ccRS.DeathKnight_2_SingleTargetCount))
	or (ccrTargetIsBoss() and ccRS.Auto_AoE_Ignore_On_Boss)
	or (not ccRS.Auto_AoE and not ccRS.Manual_AoE)	
	then	
		-- 1. Apply Diseases
		if SpellCanAttack("Outbreak")
		and (
			(not ccrTargetHasDebuff("Frost Fever") or not ccrTargetHasDebuff("Blood Plague"))
		or
			(ccrTargetHasDebuffRemaining("Frost Fever", 3) or ccrTargetHasDebuffRemaining("Blood Plague", 3))
			)
		then
			ccrCastAttack("Outbreak")
			return
		else
			-- Frost Fever [Howling Blast]
			if not ccrTargetHasDebuff("Frost Fever")
			and SpellCanAttack("Howling Blast")
			then
				ccrCastAttack("Howling Blast")
				return
			else
				-- Blood Plague [Plague Strike]
				if not ccrTargetHasDebuff("Blood Plague")
				and SpellCanAttack("Plague Strike")
				then
					ccrCastAttack("Plague Strike")
					return
				end
			end
		end;
		-- 1. Diseases are on the target
		if ccrTargetHasDebuff("Frost Fever") and ccrTargetHasDebuff("Blood Plague") then
			-- 2 Frost Strike with Killing Machine or if RP will cap
			if SpellCanAttack("Frost Strike")
			and (ccrPlayerHasBuff("Killing Machine") or ccrPlayerRunicPower() >= 85)
			then
				-- Use on Killing Machine
				ccrCastAttack("Frost Strike")
				return
			else
				-- 3. Soul Reaper on target below 35% Health.
				if ccrTargetHealth() <= 35
				and SpellCanAttack("Soul Reaper")
				then
					ccrCastAttack("Soul Reaper")
					return
				else
					-- 4. Howling Blast with Rime(Freezing Fog) or to refresh Frost Fever
					if ccrPlayerRunicPower() <= 85
					and (ccrPlayerHasBuff("Freezing Fog") or ccrTargetHasDebuffRemaining("Frost Fever", 4))
					and SpellCanAttack("Howling Blast")
					then
						ccrCastAttack("Howling Blast")
						return
					else
						-- 5. Obliterate with >= 1 Unholy Runes
						local vRuneA_Start, vRuneA_Duration, vRuneA_RuneReady = GetRuneCooldown(3)
						local vRuneB_Start, vRuneB_Duration, vRuneB_RuneReady = GetRuneCooldown(4)
						if SpellCanAttack("Obliterate")
						and (vRuneA_RuneReady or vRuneB_RuneReady)
						then
							ccrCastAttack("Obliterate")
							return
						else
							-- 6. Howling Blast to dump Frost and Unholy runes.			
							if SpellCanAttack("Howling Blast") then
								ccrCastAttack("Howling Blast")
								return
							else
								-- 7. Use Frost Strike to dump RP
								if SpellCanAttack("Frost Strike") then
									ccrCastAttack("Frost Strike")
									return
								end
							end
						end
					end
				end
			end
		end
		return
	end
	-- AoE Rotation
	-- if vTargetCount >= ccrAoERotationCount() then
	if (ccRS.Auto_AoE and vTargetCount >= ccRS.DeathKnight_2_AoECount)
	or (not ccRS.Auto_AoE and ccRS.Manual_AoE)
	then
		-- Ensure we dont cap runic power
		if SpellCanAttack("Frost Strike")
		and (ccrPlayerRunicPower() >= 85 or ccrPlayerHasBuff("Killing Machine"))
		then
			ccrCastAttack("Frost Strike")
			return
		else			
			-- Howling Blast
			if SpellCanAttack("Howling Blast") then
				ccrCastAttack("Howling Blast") 
				return
			else
				-- Death and Decay
				if SpellIsReady("Death and Decay")  then
					ccrCast("Death and Decay")
					if SpellIsTargeting() == 1 then
						CastAtLocation(Target:GetLocation())

					end;			
				else
					-- Plague strike if D&D on cd and any unholy rune available.
					local vRuneA_Start, vRuneA_Duration, vRuneA_RuneReady = GetRuneCooldown(3)
					local vRuneB_Start, vRuneB_Duration, vRuneB_RuneReady = GetRuneCooldown(4)
					if SpellCanAttack("Plague Strike")
					and (vRuneA_RuneReady or vRuneB_RuneReady)
					then
						ccrCastAttack("Plague Strike")
						return
					end
					-- Ensure Blood Plague is applied for Rolling Blood
					if ccrPlayerHasTalent("Roiling Blood")
					and (not ccrTargetHasDebuff("Blood Plague") or not ccrTargetHasDebuff("Frost Fever"))
					and (SpellCanAttack("Outbreak") or SpellCanAttack("Plague Strike"))
					then
						if SpellCanAttack("Outbreak") then ccrCastAttack("Outbreak") end;
					end
				end
			end
		end
	end
end
